<template>
  <div id="compare">  
    
    <el-form ref="form"  label-width="80px">  
     <el-row>   

        <el-col :span="12" style="display:flex;">



          <el-form-item label-width="0px" >
            <el-input v-model="telphone" placeholder="姓名/手机号" class="search"></el-input>
          </el-form-item>

           <div class="custom_button" @click="soure_but"></div>
        </el-col>


         <el-col :span="12" style="text-align: right;">
           <el-button class="custom_color_button" type="primary" @click="set_but">设置</el-button>
        </el-col>  
       
    </el-row>
   </el-form>
   <!-- 渲染数据list -->
   <compare-list :datalist="datalist" @up_list_fun="list_fun"> </compare-list>

      
   <div style="margin-top:20px;text-align: center;">
      <el-pagination
        background
        @current-change="handleCurrentChange"
        :page-size="10"  
        layout="prev, pager, next, jumper"
        :total="count">
      </el-pagination>
    </div>
     

     
     <!-- 设置 -->
    <el-dialog title="设置天数" :visible.sync="set_mtk"  width="400px">
        <div style="width:100%;"> 

           <el-form ref="form"   label-width="70px" style="width:100%;">
                  
                <el-form-item label=""  label-width="0px">
                        <el-input  v-model="day_number" placeholder="天数"></el-input>
                </el-form-item> 

            </el-form>

            <div style="text-align: center;width:50%;margin:auto;">
                <el-button type="primary" class="custom_color_button" style="width:80%;" @click="set_but_qr()">确认</el-button>
            </div>

        </div> 
    </el-dialog>
  
      
  </div>
</template>

<script>
import CompareList from '@/view/Activity/CompareList'
export default {
  name: 'compare',
  data () {
    return {
        datalist:[],
        page:1,
        count:0,
        telphone:'',
        set_mtk:false,
        day_number:''
    }
  },
 components:{
    CompareList
  },
  created(){
 
     this.list_fun()
  },
  mounted (){
    
  },
  methods: { 
      list_fun(){
           this.post("/push_new/memberList", {
              page:this.page,
              telphone:this.telphone
	         }).then(res => {
            this.count = res.result.count
            this.datalist = res.result.list           
            for(let item of this.datalist) {
               item.srcListwx = item.wx_picture
               item.srcList1 = [this.urlimg + item.wx_picture]
               item.srcListzfb = item.zfb_picture
               item.srcList2 = [this.urlimg + item.zfb_picture]
            }         
            console.log(this.datalist)
          })
      },
      soure_but(){
         this.page = 1
         this.list_fun()
      },
      set_but(){
         this.set_mtk = true
         this.day_number = ''
      },
      set_but_qr(){
          this.post("/push_new/changeSetting", {
                    day_number:this.day_number,
                }).then(res => {
                    if(res.error_code == 0){
                      this.set_mtk = false
                      this.open1(res.result,'success')  //提示框
                    }else {
                    this.open1(res.message,'warning')
                }

             })
      },
     handleSizeChange(val) {
        console.log(`每页 ${val} 条`);
      },
      handleCurrentChange(val) {
        this.page = val
        this.list_fun()
        console.log(`当前页: ${val}`);
      }
  }
}
</script>


<style scoped>

</style>
